﻿Imports DataSet_apaTableAdapters
Partial Class TarjetasA
    Inherits System.Web.UI.Page
    Dim Animales As New animalTableAdapter
    Dim IDAnimal As Integer
    Protected Sub TarjetasA_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            gvAnimales.DataSource = Animales.GetDataAnimalMod
            gvAnimales.DataBind()
        End If
    End Sub
    Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtAnimal.TextChanged
        Dim Animales As New animalTableAdapter
        gvAnimales.DataSource = Animales.GetAnimalByClave(txtAnimal.Text + "%")
        gvAnimales.DataBind()
        txtMadre.Text = ""
        txtPadre.Text = ""
        txtAnimal.Focus()
    End Sub
    Protected Sub txtPadre_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPadre.TextChanged
        gvAnimales.DataSource = Animales.GetAnimalByPadre(txtPadre.Text + "%")
        gvAnimales.DataBind()
        txtMadre.Text = ""
        txtAnimal.Text = ""
        txtPadre.Focus()
    End Sub
    Protected Sub txtMadre_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtMadre.TextChanged
        gvAnimales.DataSource = Animales.GetAnimalByMadre(txtMadre.Text + "%")
        gvAnimales.DataBind()
        txtAnimal.Text = ""
        txtPadre.Text = ""
        txtMadre.Focus()
    End Sub
    Protected Sub gvAnimales_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles gvAnimales.PageIndexChanging
        If Len(txtAnimal.Text) = 0 And Len(txtPadre.Text) = 0 And Len(txtMadre.Text) = 0 Then
            Dim newPageNumber0 As Integer = e.NewPageIndex
            gvAnimales.PageIndex = newPageNumber0
            gvAnimales.DataSource = Animales.GetAnimalByClave(txtAnimal.Text + "%")
            gvAnimales.DataBind()
        End If
        If Len(txtAnimal.Text) <> 0 Then
            Dim newPageNumber1 As Integer = e.NewPageIndex
            gvAnimales.PageIndex = newPageNumber1
            gvAnimales.DataSource = Animales.GetAnimalByClave(txtAnimal.Text + "%")
            gvAnimales.DataBind()
        End If
        If Len(txtPadre.Text) <> 0 Then
            Dim newPageNumber2 As Integer = e.NewPageIndex
            gvAnimales.PageIndex = newPageNumber2
            gvAnimales.DataSource = Animales.GetAnimalByPadre(txtPadre.Text + "%")
            gvAnimales.DataBind()
        End If
        If Len(txtMadre.Text) <> 0 Then
            Dim newPageNumber3 As Integer = e.NewPageIndex
            gvAnimales.PageIndex = newPageNumber3
            gvAnimales.DataSource = Animales.GetAnimalByMadre(txtMadre.Text + "%")
            gvAnimales.DataBind()
        End If
    End Sub
    Protected Sub gvAnimales_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gvAnimales.SelectedIndexChanged
        Dim sUrl As String = Request.Url.Authority()
        Dim codigo As String = ""
        IDAnimal = gvAnimales.SelectedIndex
        IDAnimal = gvAnimales.DataKeys(IDAnimal).Item("AnimalId")
        Session("animal") = IDAnimal
        sUrl = "http://" + sUrl
        codigo += sUrl & "/Santafe/Reportes/TarjetasARepote.aspx"
        Response.Redirect(codigo)
    End Sub
End Class
